const {Service}=require('egg');

class AddrService extends Service{
    async index(){
        let sql=`select * from address`;
        return await this.app.mysql.query(sql);
    };
    async create({id,username,address}){
        let sql=`insert into address (id,username,address) values(?,?,?)`;
        return await this.app.mysql.query(sql,[id,username,address])
    };
    async update({id,username,address}){
        let sql=`update address set username=?,address=? where id=?`;
        return await this.app.mysql.query(sql,[username,address,id]);

    };
    async show({id}){
        let sql=`select * from address where id=?`;
        return await this.app.mysql.query(sql,[id]);

    };
    async destroy({id}){
        let sql=`delete from address where id=?`;
        return await this.app.mysql.query(sql,[id])
    }
};

module.exports=AddrService;